public class BitOp {
    static public void main(String [] args) {
        byte a = -5, b = 3;

/*
 *         1000 0101
 *         1111 1011  -5的补码 (按位取反加1)
 *         1111 0110  << 1
 *             - 0000 1010 -10
 *
 *         1111 1011  -5的补码 (按位取反加1)
 *         1111 1101  >> 1
 *             -0000 0011  -3
 *
 *         0111 1101  >>> 1
 *             0x7d
 *
 *         1111 1011  -5的补码 (按位取反加1)
 *         0000 0011  3
 *       ^ 1111 1000
 *          -0000 1000 -8
 *       & 0000 0011
 *             3
 *       | 1111 1011
 *          -0000 0101 -5
 *
 *         1111 1011  -5的补码 (按位取反加1)
 *         ~ 0000 0100     4
 */
        System.out.printf("a = %d, b = %d\n", a, b);
        System.out.printf("a >> 1 = %d, a << 1 = %d\n", a >> 1, a << 1);
        System.out.printf("a >>> 1 = %x\n", a >>> 1);
        System.out.printf("~a = %d\n", ~a);
        System.out.printf("a & b = %d\n", a & b);
        System.out.printf("a ^ b = %d\n", a ^ b);
        System.out.printf("a | b = %d\n", a | b);
    }
}
